package com.anjubao.parking.municipal.parkinglot.dto;

import com.anjubao.parking.municipal.common.exception.ServiceException;
import com.anjubao.parking.municipal.common.utils.U;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;

/**
 * 停车费用计算
 *
 * @author zhuchunfeng
 * @date 2019/7/1 8:58
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel("停车总费用")
@Slf4j
public class ParkingTotalFeeDto {

    @ApiModelProperty("停车记录id 非必填 原样返回")
    private String parkingRecordId;

    @ApiModelProperty(value = "停车场id 必填 需要根据停车场匹配计费规则",required = true)
    private String parkingLotCode;

    @ApiModelProperty(value = "进场时间 必填 格式yyyy-MM-dd HH:mm:ss 单位分",required = true)
    private String enterTime;

    @ApiModelProperty(value = "出场时间 必填 格式yyyy-MM-dd HH:mm:ss 单位分",required = true)
    private String leaveTime;

    @ApiModelProperty("停车总费用 单位分 计算返回")
    private Integer totalFee;

    public void valid(){
        if (StringUtils.isAnyBlank(parkingLotCode, enterTime, leaveTime)) {
            log.info("参数有误: {}", U.json(this));
            throw new ServiceException("参数有误");
        }
    }

}
